/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package tc.maas.bulkfilerenamer.domain.dataobjects;

import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;
import tc.maas.bulkfilerenamer.domain.filemanagement.interfaces.Renamable;
import tc.maas.bulkfilerenamer.utils.enumerators.Delimiters;

/**
 *
 * @author michel
 */
public class AbstractRenamable implements Renamable {

    protected String absolutePath;
    protected String name;
    protected List<Delimiters> delimiters;

    @Override
    public String getCurrentName() {
        return name;
    }

    @Override
    public String getAbsolutePath() {
        return absolutePath;
    }

    @Override
    public List<Delimiters> getDelimiters() {
        return delimiters;
    }

    @Override
    public void setNewName(final String newName) {
        // TODO Auto-generated method stub
    }

    @Override
    public void updateDelimiters() {
        for (Delimiters d : Delimiters.values()) {
            if (name.contains(d.getDelimiterString())) {
                delimiters.add(d);
            }
        }
    }

    @Override
    public List<String> getNameFragments() {
        StringTokenizer tokenizer = null;
        List<String> stringFragments = new ArrayList<String>();

        for (Delimiters d : delimiters) {
            tokenizer = new StringTokenizer(name, d.getDelimiterString());
            while (tokenizer.hasMoreTokens()) {
                stringFragments.add(tokenizer.nextToken());
            }
        }

        return stringFragments;
    }
}
